package com.hyj.shop.project.message.service.impl;

import com.hyj.shop.project.goods.mapper.GoodsInfoMapper;
import com.hyj.shop.project.message.domain.Message;
import com.hyj.shop.project.message.mapper.MessageMapper;
import com.hyj.shop.project.message.service.MessageService;
import com.hyj.shop.project.utils.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class MessageServiceImpl implements MessageService {
    @Autowired
    private MessageMapper messageMapper;


    @Override
    public AjaxResult queryMessageCount(int userId) {
        int count = messageMapper.queryMessageCount(userId);
        AjaxResult ajaxResult =AjaxResult.success();
        ajaxResult.put("count",count);
        return ajaxResult;
    }

    @Override
    public AjaxResult messageRead(Map map) { //标记已读

        int flag = messageMapper.messageRead(map);
        System.out.println("标记已读完毕");
        System.out.println(flag);
        AjaxResult ajaxResult=AjaxResult.success();
        return ajaxResult;
    }

    @Override
    public List<Message> queryMessageList(Map map) {
        System.out.println(map.get("type"));
        List<Message> list =  messageMapper.queryMessageList(map);
        System.out.println(list);
        return list;
    }
}
